package com.controller.backend;

import com.biz.CustomerCommissionBiz;
import com.core.Result;
import com.core.ResultGenerator;
import com.entity.model.CustomerCommission;
import com.github.pagehelper.PageInfo;
import com.util.webpage.PageData;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* Created by jc on 2020/03/16.
*/
@Controller
@RequestMapping("/backend/security/customerCommission")
public class CustomerCommissionController extends BaseController<CustomerCommission>{
    @Autowired
    private CustomerCommissionBiz customerCommissionBiz;

    @RequestMapping(value = "index")
    public String index() throws Exception {
        return "/backend/security/customerCommission/list";
    }

    @RequestMapping(value = "logInfo")
    public String logInfo() throws Exception {
        return "/backend/security/customerCommission/logInfoList";
    }

    @RequestMapping(value = "commissionList")
    @ResponseBody
    public Result commissionList(HttpServletRequest request) {
        PageData cond = new PageData(request);
        List<CustomerCommission> customerCommissions = customerCommissionBiz.commissionList(cond);
        PageInfo<CustomerCommission> pageInfo = new PageInfo<CustomerCommission>(customerCommissions);
        Integer total = (int) pageInfo.getTotal();
        return ResultGenerator.genSuccessResult(customerCommissions,total);
    }

}
